dnl $Id$
dnl config.m4 for extension phpv8

dnl If your extension references something external, use with:

dnl PHP_ARG_WITH(phpv8, for phpv8 support,
dnl Make sure that the comment is aligned:
dnl [  --with-phpv8             Include phpv8 support])

dnl Otherwise use enable:

PHP_ARG_ENABLE(phpv8, whether to enable phpv8 support,
dnl Make sure that the comment is aligned:
[  --enable-phpv8           Enable phpv8 support])
PHP_REQUIRE_CXX()
PHP_ADD_LIBRARY(stdc++, "", EXTRA_LDFLAGS)
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lv8"

if test "$PHP_PHPV8" != "no"; then
  dnl Write more examples of tests here...

  dnl # --with-phpv8 -> check with-path
  dnl SEARCH_PATH="/usr/local /usr"     # you might want to change this
  dnl SEARCH_FOR="/include/phpv8.h"  # you most likely want to change this
  dnl if test -r $PHP_PHPV8/$SEARCH_FOR; then # path given as parameter
  dnl   PHPV8_DIR=$PHP_PHPV8
  dnl else # search default path list
  dnl   AC_MSG_CHECKING([for phpv8 files in default path])
  dnl   for i in $SEARCH_PATH ; do
  dnl     if test -r $i/$SEARCH_FOR; then
  dnl       PHPV8_DIR=$i
  dnl       AC_MSG_RESULT(found in $i)
  dnl     fi
  dnl   done
  dnl fi
  dnl
  dnl if test -z "$PHPV8_DIR"; then
  dnl   AC_MSG_RESULT([not found])
  dnl   AC_MSG_ERROR([Please reinstall the phpv8 distribution])
  dnl fi

  dnl # --with-phpv8 -> add include path
  dnl PHP_ADD_INCLUDE($PHPV8_DIR/include)

  dnl # --with-phpv8 -> check for lib and symbol presence
  dnl LIBNAME=phpv8 # you may want to change this
  dnl LIBSYMBOL=phpv8 # you most likely want to change this 

  dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
  dnl [
  dnl   PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $PHPV8_DIR/lib, PHPV8_SHARED_LIBADD)
  dnl   AC_DEFINE(HAVE_PHPV8LIB,1,[ ])
  dnl ],[
  dnl   AC_MSG_ERROR([wrong phpv8 lib version or lib not found])
  dnl ],[
  dnl   -L$PHPV8_DIR/lib -lm
  dnl ])
  dnl
  dnl PHP_SUBST(PHPV8_SHARED_LIBADD)
  PHP_NEW_EXTENSION(phpv8, phpv8.cpp phpv8_context.cpp phpv8_helper.cpp phpv8_jsobject.cpp, $ext_shared)
fi
